import request from '@/utils/request';

export interface GetCabinetParamsType {
  uId: string;
  userType: string;
  token: string;
  device_id?: string;
  sname?: string;
  binding?: number; // 是否铺货
  page: number;
  limit: number;
  aid?: number | string;
  aname?: number | string;
  sid?: number | string;
  status?: number | string;
  power_bank_num?: number | string;
  power_bank_num_operation?: number | string;
}

/**
 * 机柜/充电线导出参数
 * @param {Number} uId 	用户编号
 * @param {Number} userType 用户类型 1-代理，2-商户
 * @param {string} token 访问令牌
 * @param {string} device_id 设备编号
 * @param {string} sid 商户编号
 * @param {string} sname 	商户名称
 * @param {Number} aid 代理编号
 * @param {string} aname 代理名称
 * @param {Number} binding 0-全部 1-已铺货 2-未铺货
 * @param {Number} status 0-全部 1-在线 2-离线
 * @param {Number} power_bank_num 充电宝数量
 * @param {Number} power_bank_num_operation 大于还是大于小于
 */
export interface CabinetExportParams {
  uId: number;
  userType: number;
  token: string;
  device_id: string;
  sid: number | null;
  sname: string;
  aid: number | null;
  aname: string;
  binding: number | null;
  status?: number | null;
  power_bank_num: number | string
  power_bank_num_operation: number | string
}

/**
 * 获取设备列表
 * @param data
 */
export async function getCabinet(data: GetCabinetParamsType) {
  return request.post('/AgencyAdmin/Device/getCabinet', {
    data: {
      ...data,
    },
  });
}

/**
 * 获得充电线列表
 * @param data
 */
export async function getPowerLine(data: GetCabinetParamsType) {
  return request.post('/AgencyAdmin/Device/getPowerLine', {
    data: {
      ...data,
    },
  });
}

/**
 * 导出机柜
 * @param data
 */
export async function cabinetDataToCsvApi(data: CabinetExportParams) {
  return request.post('/AgencyAdmin/Device/cabinetDataToCsv', {
    data: {
      ...data,
    },
  });
}

/**
 * 导出充电线
 * @param data
 */
export async function powerLineDataToCsvApi(data: CabinetExportParams) {
  return request.post('/AgencyAdmin/Device/powerLineDataToCsv', {
    data: {
      ...data,
    },
  });
}




/**
 * 机柜/充电线导出参数
 * @param {Number} uId 	用户编号
 * @param {Number} userType 用户类型 1-代理，2-商户
 * @param {string} token 访问令牌
 * @param {string} type 类型（1充电宝 2充电线）
 * @param {string} cabinetId 设备编号
 */
export interface UnbindingParams {
  uId: number;
  userType: number;
  token: string;
  type: string;
  cabinetId: number[];
}

/**
 * 解绑设备
 * @param data
 */
export async function unbindSellerDevice(data: UnbindingParams) {
  return request.post('/AgencyAdmin/Device/DeviceIdBatchUnbinding', {
    data: {
      ...data,
    },
  });
}


/**
 * 弹出设备
 * @param {Number} uId 	用户编号
 * @param {Number} userType 用户类型 1-代理，2-商户
 * @param {string} token 访问令牌
 * @param {string} cabinet_id 机柜编号
 */
export interface DeviceInfoParams {
  uId: number | string;
  userType: number | string;
  token: string;
  cabinet_id: number | string;
}

/**
 * 设备详情
 * @param data
 */
export async function getDeviceInfo(data: DeviceInfoParams) {
  return request.post('/AgencyAdmin/Device/details', {
    data: {
      ...data,
    },
  });
}

/**
 * 弹出设备
 * @param {Number} uId 	用户编号
 * @param {Number} userType 用户类型 1-代理，2-商户
 * @param {string} token 访问令牌
 * @param {string} device_id 机柜编号
 * @param {string} power_bank_location 充电宝位置
 */
export interface PopPowerParams {
  uId: number;
  userType: number;
  token: string;
  device_id: string;
  power_bank_location?: string
}

/**
 * 弹出设备
 * @param data
 */
export async function popPowerBank(data: PopPowerParams) {
  return request.post('/AgencyAdmin/Device/popPowerBank', {
    data: {
      ...data,
    },
  });
}


/**
 * 弹出设备
 * @param data
 */
export async function popAllPowerBank(data: PopPowerParams) {
  return request.post('/AgencyAdmin/Device/popPowerBank', {
    data: {
      ...data,
    },
  });
}